﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Helper.Business.Implementation;
using Helper.Core.Entity;
using Helper.Business.Repository;

using NHibernate;

namespace Helper.Business.Implementation
{
    public class PostRepository : RepositoryBase<Post>, IPostRepository
    {
        public IEnumerable<Post> GetAllByCall(int id)
        {
            try
            {
                using (ISession session = SessionFactory.OpenSession())
                {
                    IEnumerable<Post> lquery = session.QueryOver<Post>()
                        .Where(p => p.ParentCall.Id == id)
                        .List();

                    return lquery;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}
